<template>
  <el-container>
    <el-aside width="200px">
      <el-row class="tac">
        <el-col :span="24">
          <el-menu
            default-active="1"
            class="el-menu-vertical-demo"
            unique-opened
            @open="handleOpen"
            @close="handleClose"
            text-color="#fff"
            active-text-color="#1890ff"
            router
          >
            <el-submenu index="-1">
              <template slot="title">
                <i class="el-icon-edit"></i>
                <span>博客管理</span>
              </template>
              <el-menu-item-group>
                <el-menu-item index="0">
                  <i class="el-icon-notebook-2"></i>
                  <span>博客管理</span></el-menu-item
                >
                <el-menu-item index="1">
                  <i class="el-icon-brush"></i>
                  <span>分类管理</span></el-menu-item
                >
                <el-menu-item index="2">
                  <i class="el-icon-folder-opened"></i>
                  <span>标签管理</span></el-menu-item
                >
              </el-menu-item-group>
            </el-submenu>
            <el-submenu
              :index="index.toString()"
              v-for="(item, index) in homeList"
              :key="index"
            >
              <template slot="title">
                <i :class="item.icon"></i>
                <span>{{ item.name }}</span>
              </template>
              <el-menu-item-group>
                <el-menu-item
                  :index="item2.url"
                  class="color_text"
                  v-for="(item2, index2) in item.childCategoryMenu"
                  :key="index2"
                  @click="dianji(item, item2)"
                  >{{ item2.name }}</el-menu-item
                >
              </el-menu-item-group>
            </el-submenu>
          </el-menu>
        </el-col>
      </el-row>
    </el-aside>
    <el-container>
      <el-header class="header-box">
        <my-crumbs :homeList="homeList"></my-crumbs>
      </el-header>
      <el-footer>
        <router-view></router-view>
      </el-footer>
    </el-container>
  </el-container>
</template>

<script>
import { firstitem, firstitemList } from "../../api/authority";
import myCrumbs from "../../components/myCrumbs";
export default {
  name: "home",
  data() {
    return {
      homeList: [],
      homeListItem: [],
      F: [],
    };
  },
  components: {
    "my-crumbs": myCrumbs,
  },
  created() {
    this.getHomeList();
    this.getfirstitemList();
  },
  methods: {
    async getHomeList() {
      const { data: res } = await firstitem();
      // console.log(res)
      this.homeList = res.data;
    },
    async getfirstitemList() {
      const { data: res } = await firstitemList();
      // console.log(res.data)
      this.homeListItem = res.data;
    },
    dianji(item, item2) {
      let F = [];
      let Z = [];

      // const index = Z.indexOf(F)
      // if (index !== -1) {
      // 	Z.splice(index, 1)
      // }

      // console.log(index)

      window.localStorage.setItem("fuji", JSON.stringify(item));
      window.localStorage.setItem("ziji", JSON.stringify(item2));
      this.$store.commit("getFpath", JSON.stringify(item));
      this.$store.commit("getZpath", JSON.stringify(item2));
    },
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
  },
};
</script>

<style lang="less" scoped>
.el-header {
  background-color: #fff;
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  .logo-left {
    margin-left: -20px;
    font-size: 21px;
    display: flex;
    align-items: center;
    img {
      height: 100%;
    }
  }
}
.el-aside {
  background-color: #304156;
}
.el-container {
  height: 100%;
}
.toggle-menu {
  padding: 5px;
  letter-spacing: 5px;
  text-align: center;
  background-color: rgb(123, 123, 123);
}
.el-menu {
  border-right: none;
  background-color: #304156;
}
.el-menu-item-group {
  background-color: #1f2d3d;
}
/deep/.el-menu-item {
  color: #fff;
}
.el-header .header-box {
  height: 120px;
}
</style>
